#pragma once

#include "atlwince.h"
#include "MembersDb.h"

class CSendStatusDlg :
    public CStdDialogResizeImplCancel<CSendStatusDlg>
{
public:
    enum { IDD = IDD_SEND_STATUS };

    BEGIN_DLGRESIZE_MAP(CSendStatusDlg)
        DLGRESIZE_CONTROL(IDC_EDT_MESSAGE, DLSZ_SIZE_X)
        DLGRESIZE_CONTROL(IDC_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
    END_DLGRESIZE_MAP()

    BEGIN_MSG_MAP(CSendStatusDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        COMMAND_ID_HANDLER(ID_MENU_START, OnMenuStart)
        COMMAND_ID_HANDLER(ID_MENU_DRAFTS, OnMenuDrafts)
        COMMAND_ID_HANDLER(ID_MENU_ADD_CONTACT, OnMenuAddContact)
        COMMAND_ID_HANDLER(ID_MENU_ADD_FROM_GROUP, OnMenuAddFromGroup)
        COMMAND_ID_HANDLER(ID_MENU_CLEAR_MESSAGE, OnMenuClearMessage)
        COMMAND_ID_HANDLER(ID_MENU_CLEAR_RECEPIENTS, OnMenuClearRecepients)
        COMMAND_ID_HANDLER(ID_MENU_DELETE_RECEPIENT, OnMenuDeleteRecepient)
        COMMAND_RANGE_HANDLER(IDOK, IDCANCEL, OnCloseCmd)
        COMMAND_HANDLER(IDC_EDT_MESSAGE, EN_CHANGE, OnEdtMessageChange)
        CHAIN_MSG_MAP(CStdDialogResizeImplCancel<CSendStatusDlg>)
    END_MSG_MAP()

private:

    enum
    {
        COLUMN_CONTACT,
        COLUMN_STATUS
    };

    // Handler prototypes (uncomment arguments if needed):
    //	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    //	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    //	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

    LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
    LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
    LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);

    LRESULT OnMenuStart(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuDrafts(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuAddContact(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuAddFromGroup(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuClearMessage(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuClearRecepients(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnMenuDeleteRecepient(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    LRESULT OnEdtMessageChange(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

    void OnSize(void);
    void UpdateUI(void);
    void AddMember(UINT MemberId, CString &Name);
    CString GetDraftFromId(DWORD Id);
    DWORD SaveDraft(CString &Draft);
    void PopulateList(void);

    CEdit m_MessageEdt;
    CImageList m_ImageList;
    CListViewCtrl m_List;
    bool m_Sent;
};
